package com.softvan;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;

import com.softvan.dao.BaseDao;

@SpringBootApplication
@ServletComponentScan
@MapperScan(basePackages = "com.softvan.dao", markerInterface = BaseDao.class)
public class DemoApplication implements CommandLineRunner{
    
    @Autowired
    RabbitTemplate rabbitTemplate;
    
    @Bean
    public Queue centerQueue() {
        return new Queue("my-queue");
    }
    
	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

    @Override
    public void run(String... args) throws Exception {
        rabbitTemplate.convertAndSend("my-queue", "来自RabbitMq的问候");
    }
}
